import axios from 'axios';
axios.create({
  timeout: 5000
});
//全局前置拦截器
axios.interceptors.request.use(
  config => {
    config.headers['x-access-token'] = localStorage.getItem('token')
    return config;
  },
  error => {
    console.log(error);
    return Promise.reject();
  }
);
//全局返回数据拦截器
axios.interceptors.response.use(
  response => {
    if (response.status === 200) {
      return response.data;
    } else {
      Promise.reject();
    }
  },
  error => {
    console.log(error);
    return Promise.reject();
  }
);

export const get = (url, data) => {
  return axios.get(url, {params:data })
}

export const del = (url, data) => {
  return axios.delete(url, {params:data })
}

export const post = (url, data) => {
  return axios.post(url, data)
}
